<template>
    <div>
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/welcome' }">    <i class="el-icon-location-information"></i>    首页</el-breadcrumb-item>
            <el-breadcrumb-item>权限管理</el-breadcrumb-item>
            <el-breadcrumb-item>角色列表</el-breadcrumb-item>
        </el-breadcrumb>
        <el-card>
            <el-row>
                <el-col>
                    <el-button type="success" class="fl">添加角色</el-button>
                </el-col>
            </el-row>
            <el-table :data="rolelist" stripe border>
                <el-table-column type="expand">
                    <template slot-scope="scope">
                        <pre>{{scope.row}}</pre>
                    </template>
                </el-table-column>
                <el-table-column type="index"></el-table-column>
                <el-table-column label="角色名称" prop="roleName"></el-table-column>
                <el-table-column label="角色描述" prop="roleName"></el-table-column>
                <el-table-column label="操作" prop="roleName" width="300px">
                    <template slot-scope="">
                        <el-button size="mini" type="primary" icon="el-icon-edit">编辑</el-button>
                        <el-button size="mini" type="danger" icon="el-icon-delete">删除</el-button>
                        <el-button size="mini" type="warning" icon="el-icon-share" @click="dialogVisible = true">分配角色</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-dialog
                title="分配角色"
                :visible.sync="dialogVisible"
                width="30%">
                <el-tree :data="rolelist" :props="treeProps"  show-checkbox node-key="id"></el-tree>
                <span slot="footer" class="dialog-footer">
                    <el-button @click="dialogVisible = false">取 消</el-button>
                    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
                </span>
            </el-dialog>
        </el-card>
    </div>
</template>

<script>
export default {
    data: function () {
        return {
            msg: '',
            rolelist: [],
            dialogVisible: false,
            treeProps: {
                label: 'authName',
                children: 'children'
            }
        }
    },
    created: function () {
        this.getRolesList()
    },
    methods: {
        getRolesList: function () {
            this.$http.get('roles').then(result => {
                if (result.data.meta.status !== 200) {
                    this.$message.error('获取数据失败，请稍后重试！')
                    return 0
                }
                this.rolelist = result.data.data
                console.log(this.rolelist)
            })
        },
        trydisplay: function () {
            console.log('this.id')
        }
    }
}
</script>
<style lang="less" scoped>
.el-breadcrumb{
     height: 43px;
     line-height: 43px;
     background-color: rgb(233, 238, 243);
     position:absolute;
     top: -43px;
     margin-left: 0;
     left: 0;
     padding-left: 25px;
     padding-right: 25px;
    //  transform: translateY(-30px);
    //  z-index: 999;
    .el-breadcrumb__separator {
    margin: 0 9px;
    font-weight: 700;
    color: #536da1!important;
    }
 }
 .el-table{
     margin-top: 30px;
 }
</style>
